package br.com.maps.fragments;

import java.util.Collections;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import br.com.maps.contacts.Contact;
import br.com.maps.contacts.database.ContactsDAO;
import br.com.maps.ui.ContactAdapter;
import br.com.maps.ui.MapsRamaisActivity;

public class FavouriteListFragment extends ListFragment {

	private ContactAdapter adapter;
	private MapsRamaisActivity mapsRamaisActivity;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	public void dataSetChanged() {
		ContactsDAO dao = new ContactsDAO(this.mapsRamaisActivity);
		this.adapter.setContacts(dao.findAll());
		dao.close();
		this.adapter.notifyDataSetChanged();
	}

	public void setActivity(MapsRamaisActivity mapsRamaisActivity) {
		this.mapsRamaisActivity = mapsRamaisActivity;
		this.adapter = new ContactAdapter(this.mapsRamaisActivity, Collections.<Contact> emptyList());
		this.setListAdapter(this.adapter);
	}

}
